

labels = ['A' 'B' 'C' 'D' 'F' 'H' 'K' 'M' 'O' 'P' 'S' 'W' 'Z']';

badMasks = [];
goodMasks = [];
for i=9:numel(labels)
    class = labels(i);
    path = ['./images/training/' class '/'];
    filenames = dir([path '*.jpg']); filenames = {filenames(:).name};
    figure
    for j=1:numel(filenames);
        filename = filenames{j};
        I = imread([path filename]);
        subplot(1,2,1); imshow(I); hold on
        
%         mask = GetTrainingMask(I);
        
        labeled = kmeansColor(I,3);
        subplot(1,2,2)
        bg = labeled(1,1);
        mask = labeled~=bg;
        mask = imfill(mask,'holes');
        imshow(mask,[])
        
        subplot(1,2,2); imshow(mask)
        good = input('1 for good mask, 0 for bad mask');
        if ~good
            badMasks{end+1} = filename;
        else
            save(['./images/training/masks/' filename(1:4)],'mask');
            goodMasks{end+1} = filename;
        end
        clf
    end
end

path = ['./images/training/' class '/'];
filenames = dir([path '*.jpg']); filenames = {filenames(:).name};